﻿using Class_Entity.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccess.ObjectTwo
{
   public class D_Insert
    {
        ConnectionToDataBase ex = new ConnectionToDataBase();
        DataTable tb = new DataTable();
        Cities kx = new Cities();
       Companies gx = new Companies();
       C_Services ser = new C_Services();
       Delivery_free_polices dfp = new Delivery_free_polices();
       C_News ne = new C_News();
       CC_Branches br = new CC_Branches();
       public bool InsertCompany(Companies fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[6];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.COMPANY_NAME;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.COMPANY_CODE;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.COMPANY_PHONE;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.VarChar);
           sqlParameters[3].Value = fx.COMPANY_ADDRESS;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.VarChar);
           sqlParameters[4].Value = fx.COMPANY_EMAIL;
           sqlParameters[5] = new SqlParameter("@F", SqlDbType.VarChar);
           sqlParameters[5].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertCompany", sqlParameters);
       }
       public bool InsertCity(Cities fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[3];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.CITY_CODE;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.CITY_NAME;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertCity", sqlParameters);
       }
       public bool InsertService(C_Services fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[3];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.SERVICE_CODE;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.SERVICE_NAME;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertService", sqlParameters);
       }
       public bool InsertFeePolicy(Delivery_free_polices fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[7];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.Int);
           sqlParameters[0].Value = fx.SERVICE_ID;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.Float);
           sqlParameters[1].Value = fx.DISTANCE_FROM;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.Float);
           sqlParameters[2].Value = fx.DISTANCE_TO;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.Float);
           sqlParameters[3].Value = fx.FEE_PER_KM;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.Float);
           sqlParameters[4].Value = fx.WEIGHT_FROM;
           sqlParameters[5] = new SqlParameter("@F", SqlDbType.Float);
           sqlParameters[5].Value = fx.WEIGHT_TO;
           sqlParameters[6] = new SqlParameter("@G", SqlDbType.Float);
           sqlParameters[6].Value = fx.FEE_PER_KG;
           return ex.executeInserQuery("InsertFeePolicy", sqlParameters);
       }
       public bool InsertNews(C_News fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[5];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.TITLE;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.SUBJECT;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.NText);
           sqlParameters[2].Value = fx.BODY;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.DateTime);
           sqlParameters[3].Value = fx.CREATE_DATE;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.Bit);
           sqlParameters[4].Value = fx.STATUS;
           return ex.executeInserQuery("InsertNews", sqlParameters);
       }
       public bool InsertOrderA(Orders fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[21];
           sqlParameters[0] = new SqlParameter("@ORDER_NUMBER", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.ORDER_NUMBER;
           sqlParameters[1] = new SqlParameter("@ORDER_DATE", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.ORDER_DATE;
           sqlParameters[2] = new SqlParameter("@SERVICE_ID", SqlDbType.Int);
           sqlParameters[2].Value = fx.SERVICE_ID;
           sqlParameters[3] = new SqlParameter("@ACCOUNT_ID", SqlDbType.Int);
           sqlParameters[3].Value = fx.ACCOUNT_ID;
           sqlParameters[4] = new SqlParameter("@IS_INTERNAL_DELIVERY", SqlDbType.Int);
           sqlParameters[4].Value = fx.IS_INTERNAL_DELIVERY;
           sqlParameters[5] = new SqlParameter("BRANCH_ID_FROM", SqlDbType.Int);
           sqlParameters[5].Value = fx.BRANCH_ID_FROM;
           sqlParameters[6] = new SqlParameter("@BRANCH_ID_TO", SqlDbType.Int);
           sqlParameters[6].Value = fx.BRANCH_ID_TO;
           sqlParameters[7] = new SqlParameter("@STATUS", SqlDbType.VarChar);
           sqlParameters[7].Value = fx.STATUS;
           sqlParameters[8] = new SqlParameter("@SENDER_NAME", SqlDbType.VarChar);
           sqlParameters[8].Value = fx.SENDER_NAME;
           sqlParameters[9] = new SqlParameter("@SENDER_ADDRESS", SqlDbType.VarChar);
           sqlParameters[9].Value = fx.SENDER_ADDRESS;
           sqlParameters[10] = new SqlParameter("@SENDER_CITY", SqlDbType.Int);
           sqlParameters[10].Value = fx.SENDER_CITY;
           sqlParameters[11] = new SqlParameter("@SENDER_PHONE", SqlDbType.VarChar);
           sqlParameters[11].Value = fx.SENDER_PHONE;
           sqlParameters[12] = new SqlParameter("@RECEIVER_NAME", SqlDbType.VarChar);
           sqlParameters[12].Value = fx.RECEIVER_NAME;
           sqlParameters[13] = new SqlParameter("@RECEIVER_ADDRESS", SqlDbType.VarChar);
           sqlParameters[13].Value = fx.RECEIVER_ADDRESS;
           sqlParameters[14] = new SqlParameter("@RECEIVER_CITY", SqlDbType.Int);
           sqlParameters[14].Value = fx.RECEIVER_CITY;
           sqlParameters[15] = new SqlParameter("@RECEIVER_PHONE", SqlDbType.VarChar);
           sqlParameters[15].Value = fx.RECEIVER_PHONE;
           sqlParameters[16] = new SqlParameter("@MAIL_CODE", SqlDbType.VarChar);
           sqlParameters[16].Value = fx.MAIL_CODE;
           sqlParameters[17] = new SqlParameter("@WEIGHT", SqlDbType.Float);
           sqlParameters[17].Value = fx.WEIGHT;
           sqlParameters[18] = new SqlParameter("@DESCRIPTION", SqlDbType.VarChar);
           sqlParameters[18].Value = fx.DESCRIPTION;
           sqlParameters[19] = new SqlParameter("@TOTAL_DELIVERY_FEE", SqlDbType.Float);
           sqlParameters[19].Value = fx.TOTAL_DELIVERY_FEE;
           sqlParameters[20] = new SqlParameter("@TOTAL_PAID", SqlDbType.Float);
           sqlParameters[20].Value = fx.TOTAL_PAID;          
           return ex.executeInserQuery("InsertOrderA", sqlParameters);
       }
       public bool InsertOrderB(Orders fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[13];
           sqlParameters[0] = new SqlParameter("@ORDER_NUMBER", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.ORDER_NUMBER;
           sqlParameters[1] = new SqlParameter("@ORDER_DATE", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.ORDER_DATE;
           sqlParameters[2] = new SqlParameter("@SERVICE_ID", SqlDbType.Int);
           sqlParameters[2].Value = fx.SERVICE_ID;
           sqlParameters[3] = new SqlParameter("@ACCOUNT_ID", SqlDbType.Int);
           sqlParameters[3].Value = fx.ACCOUNT_ID;
           sqlParameters[4] = new SqlParameter("@IS_INTERNAL_DELIVERY", SqlDbType.Int);
           sqlParameters[4].Value = fx.IS_INTERNAL_DELIVERY;
           sqlParameters[5] = new SqlParameter("BRANCH_ID_FROM", SqlDbType.Int);
           sqlParameters[5].Value = fx.BRANCH_ID_FROM;
           sqlParameters[6] = new SqlParameter("@BRANCH_ID_TO", SqlDbType.Int);
           sqlParameters[6].Value = fx.BRANCH_ID_TO;
           sqlParameters[7] = new SqlParameter("@STATUS", SqlDbType.VarChar);
           sqlParameters[7].Value = fx.STATUS;          
           sqlParameters[8] = new SqlParameter("@MAIL_CODE", SqlDbType.VarChar);
           sqlParameters[8].Value = fx.MAIL_CODE;
           sqlParameters[9] = new SqlParameter("@WEIGHT", SqlDbType.Float);
           sqlParameters[9].Value = fx.WEIGHT;
           sqlParameters[10] = new SqlParameter("@DESCRIPTION", SqlDbType.VarChar);
           sqlParameters[10].Value = fx.DESCRIPTION;
           sqlParameters[11] = new SqlParameter("@TOTAL_DELIVERY_FEE", SqlDbType.Float);
           sqlParameters[11].Value = fx.TOTAL_DELIVERY_FEE;
           sqlParameters[12] = new SqlParameter("@TOTAL_PAID", SqlDbType.Float);
           sqlParameters[12].Value = fx.TOTAL_PAID;
           return ex.executeInserQuery("InsertOrderB", sqlParameters);
       }
       public bool InsertBranch(CC_Branches fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[7];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.Int);
           sqlParameters[0].Value = fx.COMPANY_ID;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.Int);
           sqlParameters[1].Value = fx.CITY_ID;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.BRANCH_CODE;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.VarChar);
           sqlParameters[3].Value = fx.BRANCH_NAME;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.VarChar);
           sqlParameters[4].Value = fx.BRANCH_PHONE;
           sqlParameters[5] = new SqlParameter("@F", SqlDbType.VarChar);
           sqlParameters[5].Value = fx.ADDRESS;
           sqlParameters[6] = new SqlParameter("@G", SqlDbType.VarChar);
           sqlParameters[6].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertBranch", sqlParameters);
       }
       public bool InsertDistance(Distances fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[3];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.Int);
           sqlParameters[0].Value = fx.BRANCH_ID_FROM;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.Int);
           sqlParameters[1].Value = fx.BRANCH_ID_TO;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.Float);
           sqlParameters[2].Value = fx.KM;
           return ex.executeInserQuery("InsertDistance", sqlParameters);
       }
    }
}
